home *** CD-ROM | disk | FTP | other *** search
-
-
- *** Control 80 V1.21 ***
-
- by Jon Mattson
-
-
- One of the greatest advantages of upgrading from a C-64 to a C-128 has
- got to be the 80-column RGB capability. The improved resolution of the 8563
- chip puts the 128 on par with its much more expensive rivals from a graphics
- point of view. Text displays, such as those used in word processors,
- benefit tremendously from the extra screen capacity, allowing the 128 to be
- used as a serious work machine. For the not-so-serious, adventure games and
- the like can also take advantage of this extra space. Then, too, there are
- all sorts of nifty graphic tricks that can be produced with the 8563.
-
- Unfortunately, 'tricks' might well be the operative word in that last
- paragraph. If you have tried programming the 8563 at all, you probably
- discovered early on that it was no task to be taken lightly. Using it at
- all can be quite a sleight of hand trick, in itself. Since the chip has
- only a two byte 'window' into the 128's normal memory, even apparently
- simple tasks can be daunting. Machine language knowledge is a virtual
- necessity for speedy graphics, since BASIC 7.0 virtually ignores the chip's
- existence. Even the tried and true POKE and PEEK don't work! Thus, if you
- aren't an ML wizard with a Programmer's Reference Guide, you probably had to
- content yourself with PRINT and the occasional SYS to ROM tricks.
-
- That was until now. CONTROL80 changes all of that by adding 18 new
- keywords to BASIC 7.0: 16 commands and 2 functions that give you full and
- easy access to the 8563. (See Foreword on the new MEGA command)
-
- Using C80 is simple. Just BLOAD it into memory and SYS 4864, either in
- direct mode or early on in your program. If you are in direct mode, a
- message will inform you that it is installed. This message will not appear
- from within a program, however, since it might ruin your screen
- presentation. Generally, a simple BLOAD will suffice, but, if you have been
- playing around with BANKs and the like, you might want to use the full
- syntax:
-
- BLOAD "CONTROL80",U(DV),B0,P4864 where DV is the current drive #
-
- Once C80 is installed, the new keywords can be used just like any other
- BASIC commands. You can even abbreviate them by shifting the second letter,
- as usual. Remember that C80 must be active (not just resident) while you
- type in a program using its keywords, or they will not be tokenized
- correctly. Note also that C80 uses memory from 4864 to 6629 (only), so
- avoid POKEing around this area.
-
- Hitting the beloved STOP/RESTORE combination will not deactivate C80.
- The QUIT command (previously unimplemented on the 128) will turn it off,
- although SYS 4864 will bring it back to life. Resetting the computer will
- also turn it off; however, due to its location, C80 will still be resident
- for later use as long as you haven't POKEd over its memory space.
-
- Now let's take a look at your new resources. Certain conventions have
- been followed in this listing. Memory addresses are 0-65535, as usual, to
- allow use with both 16K and 64K VDCs. Note, however, that addresses above
- 16383 wrap around on the 16K chip (i.e. 16384 = 0). Remember that the basic
- 8563 chip is set up as follows:
-
- $0000 - 07FF 0 - 2047 Screen
- $0800 - 0FFF 2048 - 4095 Attribute
- $1000 - 1FFF 4096 - 8191 Unused
- $2000 - 2FFF 8192 - 12287 Upper Case/Graphic Char Set
- $3000 - 3FFF 12288 - 16383 Lower/Upper Case Char Set
-
- VDC register numbers (reg# below) range from 0-36. While it is not within
- the scope of this article to explain the use of every register, a simplified
- table listing each one will be given in the Appendix. A more complete
- description can be found in the C-128 Programmer's Reference Guide and many
- other sources. When in doubt, experiment with WVD - just be sure that you
- check the registers normal value with RVD first to set things back to
- normal!
-
- *** FUNCTIONS
-
- PEER (VDC address)
-
- This function allows you to check the contents of VDC memory. It
- operates just like BASIC's PEEK. For example, to find the character in the
- top left corner of the screen: PRINT PEER(0). Note that PEER is the
- counterpart of POST, below.
-
- RVD (reg#)
-
- This function (Read ViDeo register) allows you to check the contents of
- any of the 37 VDC registers. For example, A=RVD(12) would put the contents
- of register 12 in A. Note that RVD is the counterpart of WVD, below.
-
- *** COMMANDS
-
- BLOCK VDC address, number, value
-
- This command is similar to FILL, below, except that it allows you to
- fill ANY small section of VDC memory with a single value. "Address"
- indicates the starting position of the fill, and "number" (2-255) indicates
- how many locations to fill with the specified "value" (0-255) from that
- point on. One of the best uses of BLOCK is to highlight a line on the
- screen by filling attribute memory with a different color value and/or
- reverse. For example, BLOCK 2048,80,72 would highlight the entire first
- line of the screen by coloring it red and using reverse characters.
-
- DUMP type
-
- This command dumps the entire 80 column screen display to any Commodore
- compatible printer. Remember that the 8563 allows two character sets on the
- screen at the same time, but your printer will not: it will print the entire
- screen with the character set specified. "Type" may be either 0 for an
- upper case/graphics dump or 7 for a lower/upper case dump. These correspond
- to the normal and alternate character sets, respectively, in VDC terms. If
- you must access DUMP in direct mode, remember that you can use ESCAPE-X to
- move to the 40-column screen and type the command there.
-
- If your printer is numbered 5 rather than 4, you can POKE the number
- into location 5965 and the screen will be dumped to Printer #5. For
- instance:
-
- POKE5965,5:DUMP7
-
- FCOPY address, bank, character set
-
- This command allows you to convert and copy a standard 40-column font
- already in normal memory at the "address" and "bank" specified to the 8563
- chip. Since the 8563 allows two character sets simultaneously, you must
- specify which one to replace: 0 for upper case/graphics or 1 for lower/upper
- case. For example, if you wanted to replace the uc/g set with your font,
- you might enter the following:
-
- BLOAD "font",U(DV),B0,P14336:FCOPY 14336,0,0
-
- Note that you cannot simply VLOAD the font into 8563 memory, as the two
- formats are different and require conversion. Once the font has been
- FCOPYed into the VDC, you could VSAVE that, but it is actually less
- efficient this way, taking up twice as much disk space and thus, twice as
- much loading time. Stick with FCOPY if at all possible.
-
- FILL screen type, value
-
- This command allows you to fill either screen ("type" 0) or attribute
- ("type" 1) memory with a single "value" from 0-255. Screen codes are as per
- usual. Attribute codes include color, reverse, flash and the like:
-
- Bit 7 (128) Alternate Character Set
- 6 (64) Reverse Video
- 5 (32) Underline
- 4 (16) Flash
- 3 (8) Red
- 2 (4) Green
- 1 (2) Blue
- 0 (1) Intensity
-
- For example, FILL 1,154 will cause all characters to turn purple, flash and
- use the alternate character set.
-
- FINIT
-
- This command simply reinitializes the 8563's normal fonts. It is useful
- for cancelling the effects of FCOPY or undesirable POSTs into character
- memory.
-
- HOME
-
- Homes the cursor within the current window.
-
- LCLEAR first line, last line
-
- This command clears the indicated lines (0-24), including any unusual
- attribute effects such as flash and the like. Naturally, the last line must
- be higher than or equal to the value of the first. Note that lines are only
- cleared within the boundaries of the current window, and the line values
- will be offset by the position of the window from the real top of the
- screen. Thus, the 0-24 range assumes a full-screen window and will be
- smaller for smaller windows.
-
- POST VDC address, value
-
- This command allows you to place values into 8563 memory. It operates
- just like BASIC's POKE. For example, POST 0,1 will place an "A" in the top
- left corner of the screen. Note that POST is the counterpart of PEER.
-
- RECALL bytes, VDC address, from RAM address, from bank
-
- This command copies chunks of memory from normal RAM to 8563 VDC RAM.
- "Bytes" (1-65535) indicates the number of bytes to copy. "Address" and
- "bank" ranges are as per usual, 0-65535 and 0-15 respectively. When used in
- conjunction with STORE, this command can create "pop up" windows. For
- example, after opening up some free RAM space with GRAPHIC1,1:GRAPHIC5, you
- could use the following procedure:
-
- 1) STORE 4096,0,8192,0 to move the 4096 bytes of screen and attribute
- memory to location 8192 in bank 0.
-
- 2) Open the window as per usual.
-
- 3) When you are finished with the window, have the original screen reappear
- with RECALL 4096,0,8192,0.
-
- STORE bytes, VDC address, to RAM address, to bank
-
- This command copies chunks of memory from 8563 RAM to normal RAM. It is
- the reverse of, but otherwise similar to, RECALL, above.
-
- VCOL background, foreground
-
- This command alters the background and default foreground colors of the
- screen. Note that the foreground color is actually used very little, unless
- you turn off the screen attributes. As usual, color values must range from
- 1-16; however, since some of these values are not the same as on the 40-
- column screen, you may wish to experiment a bit.
-
- VLOAD "filename", VDC start address
-
- This command works in much the same manner as BLOAD except that data is
- loaded into VDC memory. The starting address is optional and defaults to
- the location from which the data was saved. Remember that variable strings
- used for filenames must be enclosed in parentheses. Note that BLOAD/BSAVE
- and VLOAD/VSAVE are compatible: memory VSAVEd from the VDC can be BLOADed to
- normal RAM and vice versa. Whether or not the data will have any meaning in
- this new context is another matter.
-
- VLOAD (and VSAVE below) both access drive 8 by default. Since you will
- want your program to work from any drive, you should make this POKE before
- using VLOAD or VSAVE:
-
- POKE6111,DV where DV is the current drive (found by PEEKing 186)
-
- VSAVE "filename", VDC start address, VDC end address+1
-
- This command works in much the same manner as BSAVE except that data is
- saved from VDC memory. As with VLOAD, you should set the drive number by
- PEEKing 186 and POKEing this value into 6111 before calling VSAVE.
-
- WVD reg#, value
-
- This command (Write to ViDeo register) allows you to write directly to
- the 8563 registers. For example, WVD 26,242 would put 242 in register 26,
- altering the screen color. This command is the counterpart of the RVD
- function. Note that some registers have bits which cannot be directly
- altered by the user; thus, the value you enter with WVD may look different
- if you later RVD the same register.
-
- QUIT
-
- This command simply turns off C80. SYS 4864 to reactivate it. Do this
- and FINIT before exiting your program.
-
- MINE
-
- This is perhaps the most unusual command of all and is aimed mainly at
- machine language programmers. Normally, issuing MINE will give an
- UNIMPLEMENTED COMMAND error. (Note! See Foreword for details on the new
- included MINE function.) However, by POKEing an address into memory
- locations 6628-6629 (low byte/high byte format), you will cause the MINE
- command to execute a machine language routine of your creation at this
- location. If your routine is relatively short (less than 542 bytes), you
- can even POKE or BLOAD it directly into C80 by starting at address 6627,
- skipping the usual jump. The demo program uses this idea to have MINE
- create "rotating characters". Note that positioning your routine in this
- area allows you to BSAVE a new version of C80 containing your command.
-
- Another good place to put this routine is in the mostly unused area from
- $B00 to $BFF, since it is also in common RAM and will allow you to avoid
- banking hassles. "POKE 6628,0: POKE 6629,11" will set this up. You can
- even have more than one MINE routine in memory at the same time, altering
- the 6628-6629 jump vector as required to switch between them. (Note!
- MEGaBasic uses 4 pages of memory, from $0B00 to $0EFF for a 'staging' area,
- where its routines are installed and executed. This has two ramifications.
- First, if you want to use RAMDOS, use page $0F. Second, if your routines
- are written to reside here, MEGaBasic will clobber them if used. Make sure
- you install them at the start of your BASIC program each time it is run.)
-
- If you would like the MINE command to take in parameters, the following
- coding will usually do the trick:
-
- JSR $0380
- JSR $AF96
- JSR $AF0C
-
- For the first value, use JSR $0386 instead of $0380. Then place this
- routine in your code to retrieve each other parameter: it will return the
- low byte in the Y-Register and the high byte in the Accumulator. For
- example, MINE 1026 would return 2 in Y and 4 in A. Commas are automatically
- handled. If you want to save some space, this is already a built-in
- subroutine in C80 at $14C1 (decimal 5313), i.e. the three can be replaced
- with JSR $14C1.
-
- I have included a demo program to get you used to the capabilities of
- the new commands. It is, frankly, fairly simplistic, since most of the
- commands are designed to be useful rather than flashy. By LISTing it,
- however, you should get a better feel for the program's many talents and how
- to put them to use for you.
-
-
- *** Appendix
-
- REG FUNCTION
- 0 Horizontal total
- 1 Horizontal displayed
- 2 Horizontal sync position
- 3 Vert/Horiz sync width
- 4 Vertical total
- 5 Vertical total adjust
- 6 Vertical displayed
- 7 Vertical sync position
- 8 Interlace mode
- 9 Character total vertical
- 10 Cursor mode, start scan
- 11 Cursor end scan line
- 12 Display start address high
- 13 Display start address low
- 14 Cursor position high
- 15 Cursor position low
- 16 Light pen vertical
- 17 Light pen horizontal
- 18 Update address high
- 19 Update address low
- 20 Attribute start address high
- 21 Attribute start address low
- 22 Character horizontal displayed/total
- 23 Character displayed vertical
- 24 Vertical smooth scroll
- 25 Horizontal smooth scroll
- 26 Foreground/background color
- 27 Address increment/row
- 28 Character base address
- 29 Underline scan line count
- 30 Block copy word count
- 31 Data
- 32 Block copy source address high
- 33 Block copy source address low
- 34 Display enable begin
- 35 Display enable end
- 36 8563 DRAM refresh/scan line
-
- * Note: The 8563 registers use a high/low byte format instead of the usual
- low/high.
-
- JM
-
- \\\\\ RETURN - Menu \\\\\
-
-